home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
076-100
/
disk_098
/
thai
/
global.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
12KB
|
348 lines
#include "quiz.h"
struct Window *window = NULL;
int file_changed = FALSE;
int scanning = -1;
char *wordptr = NULL;
int show_sentence = 0;
int show_word = 0;
int entry = -1; /* TW_ENTRY or TS_ENTRY for thai text entry */
struct thai_phrase sentence_head =
{ "" , "" , "" , 0 , 0 , NULL , NULL };
struct thai_phrase word_head =
{ "" , "" , "" , 0 , 0 , NULL , NULL };
static char buf[9][MAX_STRING]; /* warning - also refered to by sinfo[] */
struct thai_phrase screen_sentence =
{ &buf[0][0] , &buf[1][0] , &buf[2][0] , 0 , 0 , NULL , NULL };
struct thai_phrase screen_word =
{ &buf[3][0] , &buf[4][0] , &buf[5][0] , 0 , 0 , NULL , NULL };
struct thai_phrase scan =
{ &buf[6][0] , &buf[7][0] , &buf[8][0] , 0 , 0 , NULL , NULL };
struct thai_phrase *chosen_sentence = &sentence_head;
struct thai_phrase *chosen_word = &word_head;
static struct IntuiText CmdIntuiText[ NUM_CMDS ] = {
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Sentence" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Speak" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Thai" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Phonetic" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"English" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Right" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Wrong" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Add" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Delete" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Search" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Search" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Search" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Word" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Speak" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Thai" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Phonentic" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"English" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Right" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Wrong" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Add" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Delete" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Search" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Search" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Search" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Next" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Prev" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"TSEntry" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"PSEntry" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"ESEntry" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"TWEntry" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"PWEntry" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"EWEntry" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Translate" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Translate" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Replace" , NULL } ,
{ FP , BP , JAM1 , 4 , 2 , NULL , (UBYTE*)"Replace" , NULL }
};
static USHORT up_data[12*2] = {
0x0000 , 0x0000 ,
0x0001 , 0x0000 ,
0x0003 , 0x8000 ,
0x0007 , 0xC000 ,
0x000F , 0xE000 ,
0x001F , 0xF000 ,
0x003F , 0xF800 ,
0x007F , 0xFC00 ,
0x00FF , 0xFE00 ,
0x01FF , 0xFF00 ,
0x03FF , 0xFF80 ,
0x0000 , 0x0000
};
static USHORT down_data[12*2] = {
0x0000 , 0x0000 ,
0x03FF , 0xFF80 ,
0x01FF , 0xFF00 ,
0x00FF , 0xFE00 ,
0x007F , 0xFC00 ,
0x003F , 0xF800 ,
0x001F , 0xF000 ,
0x000F , 0xE000 ,
0x0007 , 0xC000 ,
0x0003 , 0x8000 ,
0x0001 , 0x0000 ,
0x0000 , 0x0000
};
static struct Image up_image =
{ 0 , 0 , 31 , 12 , 1 , &up_data[0] , 1 , 0 , NULL };
static struct Image down_image =
{ 0 , 0 , 31 , 12 , 1 , &down_data[0] , 1 , 0 , NULL };
static UBYTE undo[MAX_STRING];
static struct StringInfo sinfo[6] = {
{ (UBYTE*)&buf[0][0] , undo , 0 , MAX_STRING , 0 , 0 , 0 , 0 , 0 , 0 ,
NULL , 0 , NULL } ,
{ (UBYTE*)&buf[1][0] , undo , 0 , MAX_STRING , 0 , 0 , 0 , 0 , 0 , 0 ,
NULL , 0 , NULL } ,
{ (UBYTE*)&buf[2][0] , undo , 0 , MAX_STRING , 0 , 0 , 0 , 0 , 0 , 0 ,
NULL , 0 , NULL } ,
{ (UBYTE*)&buf[3][0] , undo , 0 , MAX_STRING , 0 , 0 , 0 , 0 , 0 , 0 ,
NULL , 0 , NULL } ,
{ (UBYTE*)&buf[4][0] , undo , 0 , MAX_STRING , 0 , 0 , 0 , 0 , 0 , 0 ,
NULL , 0 , NULL } ,
{ (UBYTE*)&buf[5][0] , undo , 0 , MAX_STRING , 0 , 0 , 0 , 0 , 0 , 0 ,
NULL , 0 , NULL }
};
#define NUM_PAIRS 5
static SHORT smallbox[ NUM_PAIRS*2 ] = {
-4,-2,
486,-2,
486,10,
-4,10,
-4,-2
};
static SHORT bigbox[ NUM_PAIRS*2 ] = {
-4,-2,
486,-2,
486,24,
-4,24,
-4,-2
};
static SHORT normbox[ NUM_PAIRS * 2 ] = {
0,0,
78,0,
78,11,
0,11,
0,0
};
static SHORT searchbox[ NUM_PAIRS * 2 ] = {
0,0,
62,0,
62,11,
0,11,
0,0
};
static struct Border smallborder =
{ 0 , 0 , FP , BP , JAM1 , NUM_PAIRS , smallbox , NULL };
static struct Border bigborder =
{ 0 , 0 , FP , BP , JAM1 , NUM_PAIRS , bigbox , NULL };
static struct Border normborder =
{ 0 , 0 , 3 , 2 , JAM1 , NUM_PAIRS , normbox , NULL };
static struct Border searchborder =
{ 0 , 0 , 3 , 2 , JAM1 , NUM_PAIRS , searchbox , NULL };
struct Gadget CmdGadget[ NUM_CMDS ] = {
{ NULL , 2 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ CHOOSE_SENTENCE ] , 0 , NULL,
CHOOSE_SENTENCE , NULL } ,
{ NULL , 2 , 92 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ SPEAK_SENTENCE ] , 0 , NULL ,
SPEAK_SENTENCE , NULL } ,
{ NULL , 2 , 79 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ THAI_SENTENCE ] , 0 , NULL ,
THAI_SENTENCE , NULL } ,
{ NULL , 2 , 106 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ PHONETIC_SENTENCE ], 0, NULL,
PHONETIC_SENTENCE , NULL } ,
{ NULL , 2 , 119 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ ENGLISH_SENTENCE ] , 0, NULL,
ENGLISH_SENTENCE , NULL } ,
{ NULL , 84 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ RIGHT_SENTENCE ] , 0 , NULL ,
RIGHT_SENTENCE , NULL } ,
{ NULL , 166 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ WRONG_SENTENCE ] , 0 , NULL ,
WRONG_SENTENCE , NULL } ,
{ NULL , 248 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ ADD_SENTENCE ] , 0 , NULL ,
ADD_SENTENCE , NULL } ,
{ NULL , 330 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ DEL_SENTENCE ] , 0 , NULL ,
DEL_SENTENCE , NULL } ,
{ NULL , 574 , 79 , 63 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&searchborder , NULL , &CmdIntuiText[ TS_SEARCH ] , 0 , NULL ,
TS_SEARCH , NULL } ,
{ NULL , 574 , 106 , 63 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&searchborder , NULL , &CmdIntuiText[ PS_SEARCH ] , 0 , NULL ,
PS_SEARCH , NULL } ,
{ NULL , 574 , 119 , 63 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&searchborder , NULL , &CmdIntuiText[ ES_SEARCH ] , 0 , NULL ,
ES_SEARCH , NULL } ,
{ NULL , 2 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ CHOOSE_WORD ] , 0 , NULL ,
CHOOSE_WORD , NULL } ,
{ NULL , 2 , 159 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ SPEAK_WORD ] , 0 , NULL ,
SPEAK_WORD , NULL } ,
{ NULL , 2 , 146 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ THAI_WORD ] , 0 , NULL ,
THAI_WORD , NULL } ,
{ NULL , 2 , 173 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ PHONETIC_WORD ] , 0 , NULL ,
PHONETIC_WORD , NULL } ,
{ NULL , 2 , 186 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ ENGLISH_WORD ] , 0 , NULL ,
ENGLISH_WORD , NULL } ,
{ NULL , 84 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ RIGHT_WORD ] , 0 , NULL ,
RIGHT_WORD , NULL } ,
{ NULL , 166 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ WRONG_WORD ] , 0 , NULL ,
WRONG_WORD , NULL } ,
{ NULL , 248 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ ADD_WORD ] , 0 , NULL ,
ADD_WORD , NULL } ,
{ NULL , 330 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ DEL_WORD ] , 0 , NULL ,
DEL_WORD , NULL } ,
{ NULL , 574 , 146 , 63 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&searchborder , NULL , &CmdIntuiText[ TW_SEARCH ] , 0 , NULL ,
TW_SEARCH , NULL } ,
{ NULL , 574 , 173 , 63 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&searchborder , NULL , &CmdIntuiText[ PW_SEARCH ] , 0 , NULL ,
PW_SEARCH , NULL } ,
{ NULL , 574 , 186 , 63 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&searchborder , NULL , &CmdIntuiText[ EW_SEARCH ] , 0 , NULL ,
EW_SEARCH , NULL } ,
{ NULL , 607 , 133 , 31 , 12 , GADGHCOMP|GADGIMAGE
#ifdef USE_ON_OFF
|GADGDISABLED
#endif
,
RELVERIFY , BOOLGADGET , (APTR)&down_image , NULL , NULL , 0 , NULL ,
NEXT_ENTRY , NULL } ,
{ NULL , 574 , 133 , 31 , 12 , GADGHCOMP|GADGIMAGE
#ifdef USE_ON_OFF
|GADGDISABLED
#endif
,
RELVERIFY , BOOLGADGET , (APTR)&up_image , NULL , NULL , 0 , NULL ,
PREV_ENTRY , NULL } ,
{ NULL , TSBASEX , TSBASEY , TSWIDTH , 22 , GADGHCOMP , RELVERIFY ,
BOOLGADGET , (APTR)&bigborder , NULL , NULL , 0 , NULL ,
TS_ENTRY , NULL } ,
{ NULL , 86 , 108 , 484 , 8 , GADGHCOMP , RELVERIFY , STRGADGET ,
(APTR)&smallborder , NULL , NULL , 0 , (APTR)&sinfo[1] , PS_ENTRY ,
NULL } ,
{ NULL , 86 , 121 , 484 , 8 , GADGHCOMP , RELVERIFY , STRGADGET ,
(APTR)&smallborder , NULL , NULL , 0 , (APTR)&sinfo[2] , ES_ENTRY ,
NULL } ,
{ NULL , TWBASEX , TWBASEY , TWWIDTH , 22 , GADGHCOMP , RELVERIFY ,
BOOLGADGET , (APTR)&bigborder , NULL , NULL , 0 , NULL ,
TW_ENTRY , NULL } ,
{ NULL , 86 , 175 , 484 , 8 , GADGHCOMP , RELVERIFY , STRGADGET ,
(APTR)&smallborder , NULL , NULL , 0 , (APTR)&sinfo[4] , PW_ENTRY ,
NULL } ,
{ NULL , 86 , 188 , 484 , 8 , GADGHCOMP , RELVERIFY , STRGADGET ,
(APTR)&smallborder , NULL , NULL , 0 , (APTR)&sinfo[5] , EW_ENTRY ,
NULL } ,
{ NULL , 494 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ TRANSLATE_SENTENCE ] , 0 ,
NULL , TRANSLATE_SENTENCE , NULL } ,
{ NULL , 494 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ TRANSLATE_WORD ] , 0 ,
NULL , TRANSLATE_WORD , NULL } ,
{ NULL , 412 , 66 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ REPLACE_SENTENCE ] , 0 ,
NULL , REPLACE_SENTENCE , NULL } ,
{ NULL , 412 , 133 , 79 , 12 , GADGHCOMP , RELVERIFY , BOOLGADGET ,
(APTR)&normborder , NULL , &CmdIntuiText[ REPLACE_WORD ] , 0 ,
NULL , REPLACE_WORD , NULL }
};
init_globals ()
{
int i;
for ( i = 0; i < NUM_CMDS; i++ )
AddGadget ( window , &CmdGadget[ i ] , (LONG)-1 );
RefreshGadgets ( window->FirstGadget , window , (LONG)NULL );
}
refresh_gadget ( num )
int num;
{
if ( num == TW_ENTRY || num == TS_ENTRY )
redraw_thai ( num );
RefreshGadgets ( &CmdGadget[ num ] , window , (LONG)NULL );
}
refresh_screen ()
{
redraw_thai ( TW_ENTRY );
redraw_thai ( TS_ENTRY );
RefreshGadgets ( &CmdGadget[ TS_ENTRY ] , window , (LONG)NULL );
}
clr_screen ()
{
screen_sentence.thai[0] = '\0';
screen_sentence.phonetic[0] = '\0';
screen_sentence.english[0] = '\0';
screen_word.thai[0] = '\0';
screen_word.phonetic[0] = '\0';
screen_word.english[0] = '\0';
refresh_screen ();
}
clr_word ()
{
screen_word.thai[0] = '\0';
screen_word.phonetic[0] = '\0';
screen_word.english[0] = '\0';
refresh_screen ();
}
clr_sentence ()
{
screen_sentence.thai[0] = '\0';
screen_sentence.phonetic[0] = '\0';
screen_sentence.english[0] = '\0';
refresh_screen ();
}